using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using BLL.BusinessLayer.DataLayer;

namespace BLL.BusinessLayer
{
    public class ClsApps_QuizzesFactory
    {

        #region data Members

        ClsApps_QuizzesSql _dataObject = null;

        #endregion

        #region Constructor

        public ClsApps_QuizzesFactory()
        {
            _dataObject = new ClsApps_QuizzesSql();
        }

        #endregion


        #region Public Methods

        /// <summary>
        /// Insert new ClsApps_Quizzes
        /// </summary>
        /// <param name="businessObject">ClsApps_Quizzes object</param>
        /// <returns>true for successfully saved</returns>
        public bool Insert(ClsApps_Quizzes businessObject)
        {
            if (!businessObject.IsValid)
            {
                throw new InvalidBusinessObjectException(businessObject.BrokenRulesList.ToString());
            }


            return _dataObject.Insert(businessObject);

        }

        /// <summary>
        /// Update existing ClsApps_Quizzes
        /// </summary>
        /// <param name="businessObject">ClsApps_Quizzes object</param>
        /// <returns>true for successfully saved</returns>
        public bool Update(ClsApps_Quizzes businessObject)
        {
            if (!businessObject.IsValid)
            {
                throw new InvalidBusinessObjectException(businessObject.BrokenRulesList.ToString());
            }


            return _dataObject.Update(businessObject);
        }
/// <summary>
        /// Update existing ClsApps_Quizzes
        /// </summary>
        /// <param name="businessObject">ClsApps_Quizzes object</param>
        /// <returns>true for successfully saved</returns>
        public bool RunSQLSP(string strSQL)
        {

            return _dataObject.RunSQL(strSQL);
        }


        /// <summary>
        /// get ClsApps_Quizzes by primary key.
        /// </summary>
        /// <param name="keys">primary key</param>
        /// <returns>Student</returns>
        public ClsApps_Quizzes GetByPrimaryKey(ClsApps_QuizzesKeys keys)
        {
            return _dataObject.SelectByPrimaryKey(keys); 
        }

        /// <summary>
        /// get list of all ClsApps_Quizzess
        /// </summary>
        /// <returns>list</returns>
        public List<ClsApps_Quizzes> GetAll()
        {
            return _dataObject.SelectAll(); 
        }

        /// <summary>
        /// get list of all ClsApps_Quizzess
        /// </summary>
        /// <returns>list</returns>
        public DataSet GetAllToDataSet()
        {
            return _dataObject.GetAllToDataSet(); 
        }

        /// <summary>
        /// get list of ClsApps_Quizzes by field
        /// </summary>
        /// <param name="fieldName">field name</param>
        /// <param name="value">value</param>
        /// <returns>list</returns>
        public List<ClsApps_Quizzes> GetAllBy(ClsApps_Quizzes.ClsApps_QuizzesFields fieldName, object value)
        {
            return _dataObject.SelectByField(fieldName.ToString(), value);  
        }
        /// <summary>
        /// Lấy về danh sách ClsApps_Quizzes by field
        /// </summary>
        /// <param name="fieldName">field name</param>
        /// <param name="value">value</param>
        /// <returns>list</returns>
        public DataSet SelectByFieldToDataSet (ClsApps_Quizzes.ClsApps_QuizzesFields fieldName, object value)
        {
            return _dataObject.SelectByFieldToDataSet(fieldName.ToString(), value);  
        }
        /// <summary>
        /// Lấy về danh sách ClsApps_Quizzes by Sql
        /// </summary>
        /// <param name="fieldName">field name</param>
        /// <param name="value">value</param>
        /// <returns>list</returns>
        public DataSet SelectSqlToDataTable (string strSql)
        {
            return _dataObject.SelectSqlToDataTable(strSql);  
        }

/// <summary>
        /// Lấy về danh sách ClsApps_Quizzes by Sql
        /// </summary>
        /// <param name="fieldName">field name</param>
        /// <param name="value">value</param>
        /// <returns>list</returns>
        public DataSet SelectTableByWhereSql (string strWhere)
        {
            return _dataObject.SelectTableByWhereSql(strWhere);  
        }
        /// <summary>
        /// delete by primary key
        /// </summary>
        /// <param name="keys">primary key</param>
        /// <returns>true for succesfully deleted</returns>
        public bool Delete(ClsApps_QuizzesKeys keys)
        {
            return _dataObject.Delete(keys); 
        }

        /// <summary>
        /// delete ClsApps_Quizzes by field.
        /// </summary>
        /// <param name="fieldName">field name</param>
        /// <param name="value">value</param>
        /// <returns>true for successfully deleted</returns>
        public bool Delete(ClsApps_Quizzes.ClsApps_QuizzesFields fieldName, object value)
        {
            return _dataObject.DeleteByField(fieldName.ToString(), value); 
        }

        #endregion

    }
}
